﻿using BLL;
using MODEL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;

namespace Loginter.ajax
{
    /// <summary>
    /// Login 的摘要说明
    /// </summary>
    public class Login : IHttpHandler,IReadOnlySessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //接收用户名和密码
            string account = context.Request.QueryString["Account"];
            string password = context.Request.QueryString["Password"];
            //context.Response.Write($"用户名：{account},密码：{password}");

            UserBLL man = new UserBLL();
            CurrenUser user = man.GetUserInfo(account,password);
            if (user!=null)
            {
               context.Session["userInfo"] = user.UserID;
                context.Response.Write("ok");
            }
            else
            {
                context.Response.Write("您输入的账户或者密码有误，请重新输入！");
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}